@isTest
private class CustomAttachment_Test 
{    
static testMethod void Testcontroller() 
{
Opportunity opp = new Opportunity();     
opp.Name = 'AAS opp test';    
opp.StageName = 'Proposal Requested by AE';       
opp.Amount=1000;    
opp.CloseDate=Date.Today();    
opp.LeadSource='Cold Call';    
insert opp;

Attachment attch= new Attachment(Name ='Testattch', ParentId = opp.Id, Body = Blob.valueOf('This is a Test'));    
insert attch;
Opportunity_Attachments_Classification__c oppattclass=new Opportunity_Attachments_Classification__c();
oppattclass.AttachmentId__c=attch.Id;
oppattclass.Attachment_Type__c='test';
insert oppattclass;
ApexPages.currentPage().getParameters().put('AttachId',attch.Id);
ApexPages.currentPage().getParameters().put('oppId',opp.Id);
CustomAttachment cstattach=new CustomAttachment();
cstattach.getAttachType();

try
{
cstattach.selectattType=null;
cstattach.save();
}
catch(Exception ex){}
cstattach.selectattType='test';
cstattach.myAttachment=attch;
cstattach.Cancel();
cstattach.save();

}
}